home *** CD-ROM | disk | FTP | other *** search
- | Copyright (C) 1991, Commodore Business Machines, Inc.
- |
- | Copyit must be called in supervisor mode with a2 pointing
- | to copyinfo struct (this is handled by Supervisor.s).
- | This code actually gets memcpy()'d into chip ram and executed there.
-
- .set ABSEXECBASE,4
-
- | struct copyinfo:
-
- .set ci_loadbuf,0
- .set ci_vaddr, 4
- .set ci_size, 8
- .set ci_entry, 12
- .set ci_d0, 16
- .set ci_d1, 20
-
-
- .text
- .globl _copyit
-
- _copyit:
- movew #0x2700,sr
-
- lea pc@(zero-.+2),a0
- pmove a0@,tc | Turn off MMU
- lea pc@(nullrp-.+2),a0
- pmove a0@,crp | Turn off MMU some more
- pmove a0@,srp | Really, really, turn off MMU
-
- | Turn off 68030 TT registers
-
- btst #2,(ABSEXECBASE)@(0x129) | AFB_68030,SysBase->AttnFlags
- beq nott | Skip TT registers if not 68030
- lea pc@(zero-.+2),a0
- .word 0xf010,0x0800 | pmove a0@,tt0 (gas only knows about 68851 ops..)
- .word 0xf010,0x0c00 | pmove a0@,tt1 (gas only knows about 68851 ops..)
-
- nott:
- movel a2@(ci_loadbuf),a0 | a0 = Pointer to text+data buffer
- movel a2@(ci_vaddr),a1 | a1 = Virtual addr to move buffer to
- movel a2@(ci_size),d0 | d0 = Size of text+data
- cmpl a0,a1 | See which direction to shift kernel
- bcc copydown | in memory, up or down (a0-a1)
- addl d0,a0 | Copy up from tail of buffer
- addl d0,a1 | to tail of kernel memory
-
- copyup: | Shuffle kernel up in memory
- moveb a0@-,a1@- | moving bytes from buffer to dest
- subl #1,d0 | one byte at a time from tail
- bcc copyup | until all bytes are moved
- bra copydone
-
- copydown: | Shuffle kernel down in memory
- moveb a0@+,a1@+ | moving bytes from buffer to dest
- subl #1,d0 | one byte at a time from head
- bcc copydown | until all bytes are moved
-
- copydone:
- movel a2@(ci_entry),a0 | Get kernel entry point
- movel a2@(ci_d0),d0 | and first argument to kernel
- movel a2@(ci_d1),d1 | and second argument to kernel
- jmp a0@ | and go for it
-
- # A do-nothing MMU root pointer (includes the following long as well)
-
- nullrp: .long 0x7fff0001
- zero: .long 0
-
-
-